/*eslint-disable*/
export function coli_points(data){
    var center=[parseFloat(data.lon),parseFloat(data.lat)];
    var a7_points = [],a10_points = [],a12_points = [];
    var Radiu_WING_A7 = null;
    var Radiu_WING_A10 = null;
    var Radiu_WING_A12 = null;
    var geojson=[];
    if(data["radiuBear1WINGA7"] != "999999"){
        Radiu_WING_A7 = {
            EN: data["radiuBear1WINGA7"],
            ES: data["radiuBear2WINGA7"],
            WS: data["radiuBear3WINGA7"],
            WN: data["radiuBear4WINGA7"]
        };

        a7_points.push.apply(a7_points,getCoilPoints(center, Radiu_WING_A7.EN, 0));	//东北方向
        a7_points.push.apply(a7_points,getCoilPoints(center, Radiu_WING_A7.ES, 90));	//东南方向
        a7_points.push.apply(a7_points,getCoilPoints(center, Radiu_WING_A7.WS, 180));	//西南方向
        a7_points.push.apply(a7_points,getCoilPoints(center, Radiu_WING_A7.WN, 270));	//西北方向
        a7_points[a7_points.length] = a7_points[0];

    }
    if(data["radiuBear1WINGA10"] != "999999"){
        Radiu_WING_A10 = {
            EN: data["radiuBear1WINGA10"],
            ES: data["radiuBear2WINGA10"],
            WS: data["radiuBear3WINGA10"],
            WN: data["radiuBear4WINGA10"]
        };
        a10_points.push.apply(a10_points,getCoilPoints(center, Radiu_WING_A10.EN, 0));	//东北方向
        a10_points.push.apply(a10_points,getCoilPoints(center, Radiu_WING_A10.ES, 90));	//东南方向
        a10_points.push.apply(a10_points,getCoilPoints(center, Radiu_WING_A10.WS, 180));	//西南方向
        a10_points.push.apply(a10_points,getCoilPoints(center, Radiu_WING_A10.WN, 270));	//西北方向
        a10_points[a10_points.length] = a10_points[0];
    }
    if(data["radiuBear1WINGA12"] != "999999"){
        Radiu_WING_A12 = {
            EN: data["radiuBear1WINGA12"],
            ES: data["radiuBear2WINGA12"],
            WS: data["radiuBear3WINGA12"],
            WN: data["radiuBear4WINGA12"]
        };
        a12_points.push.apply(a12_points,getCoilPoints(center, Radiu_WING_A12.EN, 0));	//东北方向
        a12_points.push.apply(a12_points,getCoilPoints(center, Radiu_WING_A12.ES, 90));	//东南方向
        a12_points.push.apply(a12_points,getCoilPoints(center, Radiu_WING_A12.WS, 180));	//西南方向
        a12_points.push.apply(a12_points,getCoilPoints(center, Radiu_WING_A12.WN, 270));	//西北方向
        a12_points[a12_points.length] = a12_points[0];
    }


    geojson.push({
        "type": "Feature",
        "properties": {
            "level": "A7"
        },
        "geometry": {
            "type": "Polygon",
            "coordinates": [a7_points]
        }
    });

    geojson.push({
        "type": "Feature",
        "properties": {
            "level": "A10"
        },
        "geometry": {
            "type": "Polygon",
            "coordinates": [a10_points]
        }
    });

    geojson.push({
        "type": "Feature",
        "properties": {
            "level": "A12"
        },
        "geometry": {
            "type": "Polygon",
            "coordinates": [a12_points]
        }
    });

    return geojson
}

function getCoilPoints(center, cradius, startAngle) {
    var points = [];
    var radius = cradius / 150;
    var pointNum = 30;
    var endAngle = startAngle + 90;

    var sin;
    var cos;
    var x;
    var y;
    var angle;

    for (var i = 0; i <= pointNum; i++) {
        angle = startAngle + (endAngle - startAngle) * i
            / pointNum;
        sin = Math.sin(angle * Math.PI / 180);
        cos = Math.cos(angle * Math.PI / 180);
        x = center[0] + radius * sin;
        y = center[1] + radius * cos;
        points.push([x, y]);
    }
    return points;
}